<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
         xmlns:ui="http://java.sun.com/jsf/facelets"
         xmlns:h="http://java.sun.com/jsf/html"
         xmlns:f="http://java.sun.com/jsf/core"
         xmlns:p="http://primefaces.org/ui">
    <h:head>
       <title> insert title here </title>
    </h:head>
    <h:body>
       <ui:composition template="/templates/khungchinh.xhtml">
		<ui:define name="tieudetrang">
            Quản Lý Hóa Đơn
         </ui:define>
		<ui:define name="javascrip">
			<h:outputScript library="javascrip" name="muahang.js" />
		</ui:define>
		<ui:define name="phandau">
			<div class="daude">Trang Quản Trị</div>
		</ui:define>
		<ui:define name="menungang">
		<h:form>
			<p:tabMenu activeIndex="2">  
    		<p:menuitem value="Thêm Sản Phẩm" url="admin.xhtml" styleClass="menuitem" />  
    		<p:menuitem value="Quản Lý Sản Phẩm" url="quanlysanpham.xhtml?reset=true" styleClass="menuitem"/>
    		<p:menuitem value="Quản Lý Hóa Đơn" url="#" styleClass="menuitem"/>  
			<p:menuitem value="Log Out" action="#{beanSanPham.logout}"
					styleClass="menuitem" />
			</p:tabMenu>
			</h:form>
		</ui:define>
		<ui:define name="noidung">
		<h:form id="form">
		<div id="danhsachhoadon">
		
		<p:dataTable  value="#{beanHoaDon.hddm}" var="hoadon"
					rowKey="#{hoadon.mahoadon}" paginator="true" rows="10"
					rowsPerPageTemplate="10,15,20,25"  
                selectionMode="single" 
                id="bangsanpham" styleClass="datatable">  
        <f:facet name="header">  
           <h:outputText value="Danh Sách Hóa Đơn"></h:outputText>  
        </f:facet>  
  
        <p:column headerText="Mã Hóa Đơn" filterBy="#{hoadon.mahoadon}" sortBy="#{hoadon.mahoadon}" id="mahoadon">  
            #{hoadon.mahoadon}  
        </p:column>  
  
        <p:column headerText="Tên Khách Hàng" filterBy="#{hoadon.nguoidung.ten}" sortBy="#{hoadon.nguoidung.ten}" id="tenkhachhang">  
            #{hoadon.nguoidung.ten}  
        </p:column>  
  
        <p:column headerText="Tổng Số Tiền" filterBy="#{hoadon.tongtien}" sortBy="#{hoadon.tongtien}" id="tongsotien">  
            <h:outputText value="#{hoadon.tongtien}">
            <f:convertNumber pattern="###,###,### VND"></f:convertNumber>
            </h:outputText>
        </p:column> 
        
        <p:column headerText="Đã Thanh Toán" id="dathanhtoan">  
            <p:selectBooleanCheckbox value="#{hoadon.dathanhtoan}">
            <p:ajax listener="#{beanHoaDon.suahoadon(hoadon)}"></p:ajax>
            </p:selectBooleanCheckbox>
        </p:column> 
         
    	<p:column>  
    		<h:commandLink action="#{beanHoaDon.chitiet(hoadon)}">
    		<p:button value="Xem" styleClass="button">
            </p:button>
            </h:commandLink>
            <h:commandLink action="#{beanHoaDon.xoahoadon(hoadon)}">
            <p:button value="Xóa" styleClass="button">
            </p:button>
            </h:commandLink>
        </p:column> 
    </p:dataTable>  
		
			</div>
				</h:form>
		</ui:define>
	</ui:composition>
    </h:body>
 </html>